<%--
  Created by IntelliJ IDEA.
  User: 19416
  Date: 2022-11-07
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>add</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/statics/layui/css/layui.css" media="all">
</head>
<body>
<div style="color: red">${errorMsg}</div>
<form class="layui-form layui-form-pane" action="add" method="post" enctype="multipart/form-data">
    <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-inline">
            <input type="text" name="account"  id="account"  placeholder="请输入账号" class="layui-input">
            <span id="span" style="color: red">${accountError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="realName"  autocomplete="off"  placeholder="请输入真实姓名" class="layui-input" lay-verify="required">
            <span style="color: red">${realNameError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="text" name="password"  autocomplete="off"  placeholder="请输入密码" class="layui-input" lay-verify="required">
            <span style="color: red">${passwordError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div >
            <input type="radio" name="sex" value="2" title="男" checked="" class="layui-radio">
            <input type="radio" name="sex" value="1" title="女">
            <%--            <input type="radio" name="sex" value="禁" title="禁用" disabled="">--%>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出生日期</label>
        <div class="layui-input-inline">
            <input type="text" name="birthday" lay-verify="date"  autocomplete="off"   placeholder="请输入出生日期" class="layui-input" lay-verify="required">
            <span style="color: red">${birthdayError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-inline">
            <input type="text" name="phone"  autocomplete="off"  placeholder="请输入电话" class="layui-input" lay-verify="required">
            <span style="color: red">${phoneError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-inline">
            <input type="text" name="address"  autocomplete="off"  placeholder="请输入地址" class="layui-input" lay-verify="required">
            <span style="color: red">${addressError}</span>

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-inline">
            <select name="roleId">
                <option value="">请选择角色</option>
                <option value="1">管理系统员</option>
                <option value="2">店长</option>
                <option value="3">店员</option>
            </select>
            <span style="color: red">${roleIdError}</span>
        </div>

        <div>
            证件照：
            <input type="file" name="idPic"><span style="color: red">${idPicError}</span>
        </div>

    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<%--<script src="${pageContext.request.contextPath }/statics/js/jquery-1.8.3.min.js"  charset="utf-8"></script>--%>
<script src="${pageContext.request.contextPath }/statics/layui/layui.js"  charset="utf-8"></script>


<script>

    // $('#account').blur(function () {
    //     $.get('accountExists?account='+this.value,function (data) {
    //         if(data=='1'){
    //             //存在
    //             $('#account').next().html('该账号已存在')
    //             return false
    //         } else{
    //             // 不存在
    //             $('#account').next().html('账号可用').css("color","green");
    //             return true
    //         }
    //     });
    // })
    layui.use(['form', 'layedit', 'laydate','jquery'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        var $ = layui.$;
        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');


        let bool = false;

        $('#account').blur(function () {
            $.get('accountExists?account='+this.value,function (data) {
                if(data=='1'){
                    //存在
                    $('#account').next().html('该账号已存在')
                    return false
                } else{
                    // 不存在
                    $('#account').next().html('账号可用').css("color","green");
                    return true
                }
            });
        })
    });
</script>
</body>
</html>
